<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Theoretical async signal safety</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../stacktrace.html" title="Chapter 34. Boost.Stacktrace 1.0">
<link rel="prev" href="configuration_and_build.html" title="Configuration and Build">
<link rel="next" href="acknowledgments.html" title="Acknowledgments">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="configuration_and_build.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../stacktrace.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="stacktrace.theoretical_async_signal_safety"></a><a class="link" href="theoretical_async_signal_safety.html" title="Theoretical async signal safety">Theoretical
    async signal safety</a>
</h2></div></div></div>
<p>
      In theory, walking the stack without decoding and demangling should be async
      signal safe.
    </p>
<p>
      In practice, it is not:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          Looks like a page fault while dumping the trace on a containerized/virtualized
          Windows system has a chance to deadlock. Page fault can happen easily as
          we have to write the dump either to memory or to a file.
        </li>
<li class="listitem">
          On POSIX systems a deadlock can happen if a signal is received when throwing
          an exception <a href="https://github.com/boostorg/stacktrace/issues/131" target="_top">#131</a>.
          Theoretically this can be worked around by bypassing the mutex locking
          in C++-runtime at exception throw (<a href="https://github.com/userver-framework/userver/blob/4246909c99506d3ab34bd130a5154b4acc8e87de/core/src/engine/task/exception_hacks.cpp#L241-L244" target="_top">sample
          implementation</a> in the 🐙 userver framework), or by using a very
          modern runtime (glibc-2.35+ with <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71744#c32" target="_top">modern</a>
          libgcc or <a href="https://reviews.llvm.org/D130668" target="_top">modern</a>
          LLVM's libunwind).
        </li>
<li class="listitem">
          <code class="computeroutput"><span class="special">-</span><span class="identifier">fomit</span><span class="special">-</span><span class="identifier">frame</span><span class="special">-</span><span class="identifier">pointer</span></code>
          like flags add additional complexity to the stack walking implementation,
          which may also negatively affect the signal safety.
        </li>
</ul></div>
<p>
      As a rule of thumb: do <span class="bold"><strong>not</strong></span> capture stack traces
      in signal handlers unless you are absolutely sure in your environment and inspected
      all of its source codes.
    </p>
</div>
<div class="copyright-footer">Copyright © 2016-2025 Antony Polukhin<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="configuration_and_build.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../stacktrace.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
